using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VICC_SPINSPEED
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                default:
                    dwReturn["ROWNID"] = INTEXDBC.GetSeq();
                    dwReturn["MTYPE"] = "FA503";
                    dwReturn["YNDES"] = "JH140S";
                    dwReturn["YN"] = "140";
                    dwReturn["MDAILY"] = "8.74";
                    dwReturn["MSPIND"] = "420";
                    dwReturn["CCOLOR"] = "CCOLOR";
                    dwReturn["UMIN"] = "8000";
                    dwReturn["EFF"] = "90";
                    dwReturn["TPM"] = "2060";
                    dwReturn["GKM"] = "4.22";
                    dwReturn["RTIME"] = "32947.6";
                    dwReturn["RSPEED"] = "49.47";
                    dwReturn["REMARK"] = "  ";
                    break;
                case "JLT":

                    break;
            }
        } 
        public void InsertICC_SPINSPEED(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "50.24":
                    or1.CommandText = "INSERT INTO ICC_SPINSPEED ( ROWNID,MTYPE,YNDES,YN,MDAILY,MSPIND,CCOLOR,UMIN,EFF,TPM,GKM,RTIME,RSPEED,REMARK)"
                    + " VALUES (:ROWNID:,:MTYPE:,:YNDES:,:YN:,:MDAILY:,:MSPIND:,:CCOLOR:,:UMIN:,:EFF:,:TPM:,:GKM:,:RTIME:,:RSPEED:,:REMARK:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }

        public DataSet QueryICC_SPINSPEED(DataRow dwData, int option = 1)
        {
           
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = " SELECT * FROM ICC_SPINSPEED WHERE   ROWNID=:ROWNID"; ;
                    or1.Parameters.Add("ROWNID", OracleType.NVarChar).Value = dwData["ROWNID"].ToString();
                    break;
                case 9999:
                    or1.CommandText = " SELECT * FROM ICC_SPINSPEED";
                    break;
                default:
                    break;
            }
            SResult = Connect2Proxy(or1);
             
                SResult.Tables[0].TableName = TableName;
            
            return SResult;
        }
        public void DSSPEED01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_SPINSPEED"
                + " WHERE ROWNID=:ROWNID:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void DSSPEED02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_SPINSPEED";
            Connect2Proxy(or1);
        }
        public void UpdateICC_SPINSPEED(DataRow dwData, int options = 1)
        {
            
            or1 = OracleDB.CreateCommand();
            switch (options)
            {
                default:
                case 1:
                    or1.CommandText = "UPDATE ICC_SPINSPEED SET ROWNID=:ROWNID:,MTYPE=:MTYPE:,YNDES=:YNDES:,YN=:YN:,MDAILY=:MDAILY:,MSPIND=:MSPIND:,CCOLOR=:CCOLOR:,UMIN=:UMIN:,EFF=:EFF:,TPM=:TPM:,GKM=:GKM:,RTIME=:RTIME:,RSPEED=:RSPEED:,REMARK=:REMARK:"
                        + " WHERE ROWNID=:ROWNID:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break;
            }

            Connect2Proxy(or1);
        }
    }
}
